#ifndef MENUFPLN
#define MENUFPLN

#include "general.h"
#include "fmmtplan.h"
#include "savefile.h"
#include "vetores.h"
#include "fmmtcir.h"

extern sistema ms;
extern fmmt estator, rotor, resul;
extern void controleRedisplay();

extern int janfmmtplan;
extern bool showfmmtplan;
extern bool ok, step;

extern void vetoresMenu(int id);

int menufplan, sube_fplan, subpt_fplan, subsave_fplan;

bool realcefmmtplan=false;

void fmmtplanMenu(int id)
{
	bool oldst;
	switch(id)
	{
	case 0:
		break;
	case 1:
	case 2:
	case 3:	
		vetoresMenu(id);
		break;
	case 4:
		realcefmmtplan=!realcefmmtplan;
		if(realcefmmtplan) {glutSetWindow(janfmmtplan);glEnable(GL_LINE_SMOOTH);}
		else {glutSetWindow(janfmmtplan);glDisable(GL_LINE_SMOOTH);}
		break;
	case 5:
		glutSetWindow(janfmmtplan);
		glutHideWindow();
		showfmmtplan=false;
		break;
	case 7:
		showcmps=!showcmps;
		controleRedisplay();
		break;
	case 8:
		showres=!showres;
		controleRedisplay();		
		break;


	case 101:
	case 102:	
	case 103:	
	case 104:	
	case 201:
	case 202:	
	case 203:	
	case 204:	
		vetoresMenu(id);
		break;
		
	case 401:
		oldst=ok;
		ok=false;
		jansave(6);
		break;
	}
}

void fmmtplanCreateMenu(void)
{
	sube_fplan=glutCreateMenu(fmmtplanMenu);
	glutAddMenuEntry("+ 20%",101);
	glutAddMenuEntry("+ 10%",102);
	glutAddMenuEntry("- 10%",103);
	glutAddMenuEntry("- 20%",104);
	
	subpt_fplan=glutCreateMenu(fmmtplanMenu);
	glutAddMenuEntry("+ 20%",201);
	glutAddMenuEntry("+ 10%",202);
	glutAddMenuEntry("- 10%",203);
	glutAddMenuEntry("- 20%",204);

//	subsave_fplan=glutCreateMenu(fmmtplanMenu);
//	glutAddMenuEntry(MSG103,401);
				
	menufplan=glutCreateMenu(fmmtplanMenu);
	glutAddSubMenu(MSG93,sube_fplan);
	glutAddSubMenu(MSG94, subpt_fplan);
	glutAddMenuEntry("",0);
	glutAddMenuEntry(MSG95,1);
	glutAddMenuEntry(MSG96,2);
	glutAddMenuEntry("",0);
	glutAddMenuEntry(MSG97, 7);
	glutAddMenuEntry(MSG98,8);
	glutAddMenuEntry("",0);
//	glutAddSubMenu(MSG99,subsave_fplan);
//	glutAddMenuEntry("",0);
	glutAddMenuEntry(MSG100, 3);
	glutAddMenuEntry("",0);
	glutAddMenuEntry(MSG101,4);
	glutAddMenuEntry(MSG102,5);

	glutAttachMenu(GLUT_RIGHT_BUTTON);
}

#endif
